package com.study.hot.jetpack.paging.paging3

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

/**
 * <pre>
 *     author : slx
 *     time   : 2021/02/02
 *     desc   :
 * </pre>
 */
object RetrofitService {
    lateinit var okHttpClient: OkHttpClient

    private const val BASEURL = "https://www.wanandroid.com/"

    fun <T> createServiceApi(clz: Class<T>): T {
        okHttpClient = OkHttpClient.Builder().build()
        val retrofit = Retrofit.Builder()
                .baseUrl(BASEURL)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create())
                .build()

        return retrofit.create(clz)
    }
}